// 第一步:引入路由器
import { createRouter, createWebHistory } from "vue-router";

// 第二步:引入一个个可能需要的vue组件
import Home from "@/components/Home.vue";
import User from "@/components/User.vue";
import Product from "@/components/Product.vue";
import Detail from "@/components/Detail.vue";


// 第三步:创建路由器
const router = createRouter({
    history: createWebHistory(),    // 路由工作模式
    routes: [{
        path: '/home',
        component: Home
    }, {
        path: '/user',
        component: User
    }, {
        name: 'sp',
        path: '/product',
        component: Product,
        children: [{
            name: 'xq',
            path: 'detail/:id/:name/:price', // 嵌套路由不能以/开头,需要省略/
            component: Detail
        }]
    }]
})


// 第四步:将路由暴露出去
export default router